<?php
require( 'php/database.php' );
require( 'config.php' );

//
if ( isset( $_GET[ 'id' ] ) ) {
    $iProductId = $_GET[ 'id' ];
} else {
    $iProductId = 0;
}

//
if ( $iProductId != 0 ) {
    //
    $iLanguageId = 1;
    
    $sSQL  = "SELECT p.*, m1.message_text AS product_text, m2.message_text AS product_description";
    $sSQL .= "  FROM products p, messages m1, messages m2";
    $sSQL .= " WHERE p.product_id = m1.product_id AND p.product_id = m2.product_id";
    $sSQL .= "   AND m1.message_type = 0 AND m2.message_type = 1";
    $sSQL .= "   AND m1.language_id = ${iLanguageId} AND m2.language_id = ${iLanguageId}";
    $sSQL .= "   AND p.product_id = ${iProductId}";

    //
    $oDB = new Database( $g_sMySqlServer,
                         $g_sMySqlUsername,
                         $g_sMySqlPassword,
                         $g_sMySqlDatabase );
    
    $aRows = $oDB->fetch( $sSQL );

    if ( count( $aRows ) == 1 ) {
        //
        $aRow = $aRows[ 0 ];        
    }
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
    <title>
      Warehouse - Details
    </title>
    <link rel="stylesheet" type="text/css" href="css/style.css">
  </head>
  <body>
    <table width="100%" cellspacing="0">
      <tr>
        <th width="25%">
          Code
        </th>
        <td width="*">
          <?php echo $aRow[ 'product_code' ]; ?>
          </td>
      </tr>
      <tr>
        <th width="25%">
          Category
        </th>
        <td width="*">
          <?php echo $aRow[ 'product_category' ]; ?>
          </td>
      </tr>
      <tr>
        <th width="25%">
          Text
        </th>
        <td width="*">
          <?php echo $aRow[ 'product_text' ]; ?>
          </td>
      </tr>
      <tr>
        <th width="25%">
          Description
        </th>
        <td width="*">
          <?php echo $aRow[ 'product_description' ]; ?>
          </td>
      </tr>
      <tr>
        <th width="25%">
          Price
        </th>
        <td width="*">
          <?php echo $aRow[ 'product_price' ]; ?>
          </td>
      </tr>
    </table>
  </body>
</html>
<?php
} else {
}
?>
